package org.jctc.els.modules.biz.controller.customer;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import org.jctc.els.modules.biz.service.customer.ICustomerService;
import org.jctc.els.modules.biz.entity.customer.Customer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 客服表 前端控制器
 * </p>
 *
 * @author lyh
 * @since 2021-03-29
 */
@Api(tags = {"客服表"})
@RestController
@AllArgsConstructor
@RequestMapping("/customer")
public class CustomerController {

    private ICustomerService customerService;


    @ApiOperation(value = "新增客服表")
    @PostMapping()
    public R save(@RequestBody Customer customer){
		boolean result = customerService.save(customer);
        return R.status(result);
    }

    @ApiOperation(value = "删除客服表")
    @DeleteMapping("{id}")
    public R remove(@PathVariable("id") Long id){
		boolean result = customerService.remove(id);
		return R.status(result);
    }

    @ApiOperation(value = "更新客服表")
    @PutMapping()
    public R edit(@RequestBody Customer customer){
        return R.status(customerService.edit(customer));
    }

    @ApiOperation(value = "查询客服表分页数据")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "页码"),
        @ApiImplicitParam(name = "pageSize", value = "每页条数")
    })
    @GetMapping()
    public R<Page<Customer>> selectListByPage(@RequestParam(value = "pageNum") Integer pageNum,
                                           @RequestParam(value = "pageSize") Integer pageSize){
		Page<Customer> customerPage = customerService.selectListByPage(pageNum, pageSize);
		return R.data(customerPage);
    }

    @ApiOperation(value = "根据id查询客服表")
    @GetMapping("{id}")
    public R selectById(@PathVariable("id") Long id){
        return R.data(customerService.selectById(id));
    }

}
